<template>
  <view v-if="visible" class="modal-overlay" @click="closeModal">
    <view class="modal-container" @click.stop>
      <!-- 弹窗头部 -->
      <view class="modal-header">
        <text class="modal-title">{{ title }}</text>
        <button class="close-btn" @click="closeModal">
          <text class="close-icon">✕</text>
        </button>
      </view>
      
      <!-- 弹窗内容 -->
      <view class="modal-content">
        <slot></slot>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'GameModal',
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    }
  },
  methods: {
    closeModal() {
      this.$emit('close')
    }
  }
}
</script>

<style scoped>
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5rpx);
}

.modal-container {
  width: 90%;
  max-width: 800rpx;
  max-height: 80%;
  background: rgba(30, 41, 59, 0.95);
  border-radius: 20rpx;
  border: 1rpx solid #374151;
  box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24rpx 32rpx;
  border-bottom: 1rpx solid #374151;
  background: rgba(55, 65, 81, 0.8);
}

.modal-title {
  font-size: 32rpx;
  font-weight: bold;
  color: #fcd34d;
}

.close-btn {
  width: 60rpx;
  height: 60rpx;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.8);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.close-btn:active {
  background: rgba(239, 68, 68, 1);
  transform: scale(0.95);
}

.close-icon {
  font-size: 24rpx;
  color: white;
  font-weight: bold;
}

.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 24rpx;
}
</style>
